import request from '@/utils/request'

/**
 * 添加自定义分组
 * @param {groupName,groupType} data 
 * @returns 
 */
export function addGroup(data) {
  return request({
    url: '/duty/group',
    method: 'post',
    data: data
  })
}

/**
 * 修改自定义分组
 * @param {groupName,groupId} data 
 * @returns 
 */
export function editGroup(data) {
  return request({
    url: '/duty/group',
    method: 'put',
    data: data
  })
}

/**
 * 获取分组列表
 * @param {*} query 
 * @returns 
 */
export function listGroup(query) {
  return request({
    url: '/duty/group/list',
    method: 'get',
    params: query
  })
}

/**
 * 删除分组
 * @param {*} groupId 
 * @returns 
 */
export function delGroup(groupId) {
  return request({
    url: '/duty/group/' + groupId,
    method: 'DELETE',
  })
}

/**
 * 对成员进行批量分组
 * @param {groupid, members} data 
 * @returns 
 */
export function addToGroup(data) {
  return request({
    url: '/duty/group_relation',
    method: 'post',
    data: data
  })
}

/**
 * 根据自定义分组ID获取用户列表
 * @param {*} groupId 
 */
export function listUserByGroupId(groupId) {
  return request({
    url: '/duty/group_relation/' + groupId,
    method: 'get',
  })
}

/**
 * 批量退组
 * @param {members} data 
 * @returns 
 */
export function dropUserGroup(data) {
  return request({
    url: '/duty/group_relation',
    method: 'DELETE',
    data: data
  })
}

/**
 * 获取用户列表
 * @param {*} query 
 * @returns 
 */
export function listUser(query) {
  return request({
    url: '/duty/group_relation/userList',
    method: 'get',
    params: query
  })
}